package ve.com.wayoyo.wuml_case;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.Display;
import android.view.ViewGroup.LayoutParams;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ListView;

public class FileSelector extends Dialog {

	private ArrayAdapter<String> adapter;
	
	public FileSelector(Context context,ArrayAdapter<String> adapter) {
		super(context);
		this.adapter = adapter;
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {	
		super.onCreate(savedInstanceState);
		setContentView(R.layout.file_selector);
		setTitle("Seleccione el archivo");
		int pageWidth = UserPref.getInstancia().getWinWidth();
		int pageHeight = UserPref.getInstancia().getWinHeight();			
		if (pageHeight<=480){
			LayoutParams params = getWindow().getAttributes();	
			params.width=LayoutParams.MATCH_PARENT;
			params.height= 200;
			ListView lista = (ListView)findViewById(R.id.listFiles);
			lista.setLayoutParams(params);
		}
		CheckBox nuevoArchivo = (CheckBox)findViewById(R.id.existNewFile);
		final EditText etNewFile = (EditText)findViewById(R.id.NewFile);
		nuevoArchivo.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
			public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
				if (isChecked) {
					etNewFile.setEnabled(true);
				}
				else {
					etNewFile.setEnabled(false);
				}
			}
		});
		
		ListView listView = (ListView) findViewById(R.id.listFiles);
		String[] values;
		values = new String[] { "1","2","3","4","5","6","7","8" };		
//		this.adapter.
		this.adapter.add(String.valueOf(pageHeight));
		this.adapter.add("1");
		this.adapter.add("1");
		this.adapter.add("1");
		this.adapter.add("1");
		this.adapter.add("1");
		this.adapter.add("1");
		this.adapter.add("1");
		this.adapter.add("1");
		this.adapter.add("1");
		this.adapter.add("1");
		this.adapter.add("1");
		this.adapter.add("1");
		this.adapter.add("1");
		
		// Assign adapter to ListView
		listView.setAdapter(adapter);
	}

}
